//
//  SettingCell.m
//  Finance
//
//  Created by cheng xiang on 13-4-15.
//  Copyright (c) 2013年 cheng xiang. All rights reserved.
//

#import "SettingCell.h"

@implementation SettingCell
@synthesize titleLabel = _titleLabel, selection = _selection, delegate = _delegate;
@synthesize section = _section;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 180, self.contentView.bounds.size.height)];
        _titleLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_titleLabel];
        
        _selection = [[UISwitch alloc] initWithFrame:CGRectMake(220, 10, 80, self.contentView.bounds.size.height - 20)];
        [_selection addTarget:self action:@selector(catchEvent) forControlEvents:UIControlEventValueChanged];
        [self.contentView addSubview:_selection];
    }
    return self;
}

- (void)catchEvent
{
    if ([_delegate respondsToSelector:@selector(clickOnSwitch:atSection:)]) {
        [_delegate clickOnSwitch:_selection.on atSection:_section];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
